
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
from api_test.testcases.user_action.login_test import TestCaseLogin


class TestShopList(HttpRunner):

    config = Config("商铺列表").base_url("${get_http_host()}").verify(False).export(*["shopId", "token"])

    teststeps = [

        Step(
            RunTestCase("登录")
            .with_variables(**{"phone": "18222878910", "password": "aaaaaa"})
            .call(TestCaseLogin)
            .export(*["token"])
        ),

        Step(
            RunRequest("商铺列表")
            .post("/shop/shopList")
            .with_headers(**{"OKCLOUD-TOKEN": "$token"})
            .extract()
            .with_jmespath("body.result[0].pid", "shopId")
            .validate()
            .assert_equal("body.message", "Success")
            .assert_equal("body.code", 200)
        )

    ]


if __name__ == "__main__":
    TestShopList().test_start()
